home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blitzblank / sources / bb.flash < prev    next >
Text File  |  1993-09-17  |  5KB  |  243 lines

  1. ;BB.Flash - Blanker-module for BlitzBlank
  2. ;Copyright 1993 by Thomas Boerkel
  3.  
  4. CloseEd
  5.  
  6. NEWTYPE.spritedata
  7. a.w
  8. b
  9. c
  10. d
  11. e
  12. f
  13. End NEWTYPE
  14.  
  15. NEWTYPE.tags
  16. a.l
  17. b
  18. c
  19. d
  20. e
  21. f
  22. End NEWTYPE
  23.  
  24. DEFTYPE.spritedata *sprdata
  25. DEFTYPE.SimpleSprite spr
  26. DEFTYPE.Screen *myscreen
  27. DEFTYPE.NewScreen newscreen
  28. DEFTYPE.Message *msg
  29. DEFTYPE.MsgPort *port
  30. DEFTYPE.tags tags
  31. DEFTYPE.l
  32.  
  33. Statement stringborder{x,y,w,h}
  34. Wline x+1,y+h+2,x+1,y,x+w+8,y,1
  35. Wline x+w+10,y-1,x+w+10,y+h+4,x-1,y+h+4,1
  36. Wline x,y+h+3,x,y,1
  37. Wline x+w+11,y-1,x+w+11,y+h+4,1
  38. Wline x-1,y+h+3,x-1,y-1,x+w+10,y-1,2
  39. Wline x+w+9,y,x+w+9,y+h+3,x+1,y+h+3,2
  40. Wline x-2,y+h+4,x-2,y-1,2
  41. Wline x+w+8,y+1,x+w+8,y+h+2,2
  42. End Statement
  43.  
  44. Statement drawflash{x,y,b}
  45. SHARED *rp,width,height
  46. dx1=Int(Rnd(61))-30
  47. dy1=Int(Rnd(100))+10
  48. dx2=Int(Rnd(41))-20
  49. dy2=Int(Rnd(100))+10
  50. If y+dy1<height AND y+dy2<height
  51.   Move_ *rp,x,y
  52.   Draw_ *rp,x+dx1,y+dy1
  53.   drawflash{x+dx1,y+dy1,b}
  54.   b+1
  55.   If b<2 AND y>height/4 AND Rnd(3)<1
  56.     Move_ *rp,x,y
  57.     Draw_ *rp,x+dx2,y+dy2
  58.     drawflash{x+dx2,y+dy2,b}
  59.   EndIf
  60. EndIf
  61. End Statement
  62.  
  63. al=0
  64. Select Par$(1)
  65.   Case "BLANK"
  66.  
  67.     name$="BB.BlankModule"+Chr$(0)
  68.     *port=CreateMsgPort_()
  69.     *port\mp_Node\ln_Name=&name$
  70.     *port\mp_Node\ln_Pri=1
  71.     AddPort_ *port
  72.  
  73.     SetTaskPri_ FindTask_(0),Val(Par$(8))
  74.     *sprdata=AllocMem_(SizeOf.spritedata,#MEMF_CHIP|#MEMF_CLEAR)
  75.  
  76.     Gosub readconfig
  77.  
  78.     width=Val(Par$(2))
  79.     height=Val(Par$(3))
  80.     mode=Val(Par$(4))
  81.     monitor=Val(Par$(5))
  82.     depth=1
  83.     colors=2^depth
  84.     title$="BB.Flash.Screen"+Chr$(0)
  85.     newscreen\LeftEdge=0,0,width,height,depth
  86.     newscreen\ViewModes=0,#CUSTOMSCREEN|#SCREENBEHIND,0,&title$
  87.     tags\a=#SA_DisplayID
  88.     tags\b=$10000*monitor+mode
  89.     tags\c=0
  90.     *myscreen=OpenScreenTagList_(newscreen,tags)
  91.     If *myscreen
  92.       *vp=*myscreen\ViewPort
  93.       *rp=*myscreen\RastPort
  94.       SetRGB4_ *vp,0,0,0,0
  95.       SetRGB4_ *vp,1,0,0,0
  96.       SetAPen_ *rp,0
  97.       RectFill_ *rp,0,0,width-1,height-1
  98.       ScreenToFront_ *myscreen
  99.       VWait
  100.       ChangeSprite_ 0,spr,*sprdata
  101.  
  102.       Repeat
  103.  
  104.         SetAPen_ *rp,1
  105.         For i=1 To Rnd(20)
  106.           Delay_ 5
  107.           *msg=GetMsg_(*port)
  108.           If *msg
  109.             e=1
  110.             i=25
  111.           EndIf
  112.         Next i
  113.         If e=0
  114.           VWait
  115.           SetRGB4_ *vp,0,0,10,10
  116.           SetRGB4_ *vp,1,15,15,15
  117.           af=Int(Rnd(flash))+1
  118.           For i=1 To af
  119.             drawflash{width/4+Rnd(width/2),0,0}
  120.           Next i
  121.           Delay_ af+2
  122.           VWait
  123.           SetRGB4_ *vp,0,0,0,0
  124.           SetRGB4_ *vp,1,0,0,0
  125.           SetAPen_ *rp,0
  126.           RectFill_ *rp,0,0,width-1,height-1
  127.           *msg=GetMsg_(*port)
  128.         EndIf
  129.       Until *msg
  130.  
  131.  
  132.       CloseScreen_ *myscreen
  133.     EndIf
  134.     FreeMem_ *sprdata,SizeOf.spritedata
  135.     RemPort_ *port
  136.     DeleteMsgPort_ *port
  137.  
  138.  
  139.   Case "INFO"
  140.  
  141.     title$="Flash"+Chr$(0)
  142.     reqtext$="Flash - Module for BlitzBlank"+Chr$(10)
  143.     reqtext$+Chr$(169)+" 1993 by Thomas Brkel"+Chr$(10)+Chr$(10)
  144.     reqtext$+"You see flashes in the dark."+Chr$(10)+Chr$(10)
  145.     reqtext$+"Choose the max. number of flashes in the config-window."+Chr$(0)
  146.     gadget$="OK"+Chr$(0)
  147.  
  148.     easy.EasyStruct\es_StructSize=SizeOf.EasyStruct
  149.     easy\es_Title=&title$
  150.     easy\es_TextFormat=&reqtext$
  151.     easy\es_GadgetFormat=&gadget$
  152.  
  153.     EasyRequestArgs_ 0,easy,0,0
  154.  
  155.   Case "CONFIG"
  156.     *myscreen=LockPubScreen_(0)
  157.     width=*myscreen\Width
  158.     height=*myscreen\Height
  159.     font=*myscreen\Font\ta_YSize
  160.     Gosub readconfig
  161.     WbToScreen 0
  162.     BorderPens 0,0
  163.     StringGadget 0,100,25,0,0,4,40
  164.     Window 0,width/2-90,height/2-25,180,50,$100e,"Flash",1,2,0
  165.     stringborder{100,25,40,8}
  166.     WColour 2
  167.     WLocate 32,24-font
  168.     Print "Flash:"
  169.     WLocate 32,24-font+8
  170.     Print "(1-5)"
  171.     SetString 0,0,Str$(flash)
  172.     ActivateString 0,0
  173.     Repeat
  174.       ev=WaitEvent
  175.     Until ev=$200 OR ev=$40
  176.     flash=Val(StringText$(0,0))
  177.     Free Window 0
  178.     Gosub writeconfig
  179.     UnlockPubScreen_ 0,*myscreen
  180. End Select
  181.  
  182. End
  183.  
  184.  
  185. .readconfig
  186. path$=Par$(9)
  187. For i=10 To NumPars
  188.   path$=path$+" "+Par$(i)
  189. Next i
  190. If ReadFile(0,path$+"BB.Modules.config")
  191.   FileInput 0
  192.   While NOT Eof(0)
  193.     If Edit$(100)="*** Flash ***"
  194.       flash=Val(Edit$(5))
  195.     EndIf
  196.   Wend
  197.   DefaultInput
  198.   CloseFile 0
  199. EndIf
  200. Gosub checkval
  201. Return
  202.  
  203.  
  204. .writeconfig
  205. Gosub checkval
  206. If ReadFile(0,path$+"BB.Modules.config")
  207.   If WriteFile(1,path$+"BB.Modules.temp")
  208.     FileInput 0
  209.     FileOutput 1
  210.     While NOT Eof(0)
  211.       f$=Edit$(100)
  212.       If f$="*** Flash ***"
  213.         Repeat
  214.           f2$=Edit$(100)
  215.         Until Eof(0) OR Left$(f2$,3)="***"
  216.         If NOT Eof(0) Then NPrint f2$
  217.       Else
  218.         NPrint f$
  219.       EndIf
  220.     Wend
  221.     CloseFile 1
  222.   EndIf
  223.   CloseFile 0
  224. EndIf
  225. KillFile path$+"BB.Modules.config"
  226. f$=path$+"BB.Modules.temp"+Chr$(0)
  227. f2$=path$+"BB.Modules.config"+Chr$(0)
  228. Rename_ &f$,&f2$
  229. If OpenFile(0,path$+"BB.Modules.config")
  230.   FileOutput 0
  231.   FileSeek 0,Lof(0)
  232.   NPrint "*** Flash ***"
  233.   NPrint flash
  234.   CloseFile 0
  235. EndIf
  236. Return
  237.  
  238. .checkval
  239. If flash<1 Then flash=1
  240. If flash>5 Then flash=5
  241. Return
  242.  
  243.